<template>
  <section class="head">
    <section class="headLeft">
      <router-link to="/home">
        <span class="logo">机密空间</span>
      </router-link>
    </section>

    <section class="headCenter">
      <div class="searchBox">
        <input type="text" class="search" placeholder="查找空间" v-model="name">
        <i class="icon_style iconfont icon-sousuo1" @click="save_name"></i>
      </div>
    </section>

    <section class="headRight">
      <div class="mint-header-button is-right">
        <router-link to="/create_post">
          <i class="icon_style iconfont icon-add"></i>
        </router-link>
      </div>
    </section>
  </section>
</template>

<script>
  import {mapState, mapMutations} from 'vuex'

  export default {

    components: {

    },
    data () {
    return {
      name:""
    }
  },
    mounted(){
      if (this.$route.path.indexOf('search_room') === 1){
        this.name = this.$store.state.roomName
      }
    },
    methods: {
      ...mapMutations([
        'SAVE_ROOM_NAME'
      ]),
      save_name(){
        this.SAVE_ROOM_NAME(this.name);
        if (this.$route.path.indexOf('search_room') === 1){
          this.preventRepeat = false;
          this.$router.go(0);
        }else{
          this.preventRepeat = false;
          this.$router.push('/search_room');
        }
      }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
  @import '../../style/mixin';

  .head{
    background-color: #33CCFF;
    position: fixed;
    z-index: 999;
    left: 0;
    right: 0;
    top: 0;
    @include wh(100%, 1.5rem);
    display: flex;
    box-shadow: 0 -0.026667rem 0.053333rem rgba(0,0,0,.1);


    .headLeft{
      flex: 2;
      display: flex;
      text-align: center;
      flex-direction: column;
      align-items: center;
      .logo{
        color: #FFFFFF;
        font-size: 0.9rem;
        font-weight: bold;
      }
    }

    .headCenter{
      flex: 4;
      display: flex;
      text-align: center;
      flex-direction: column;
      align-items: center;

      .searchBox{
        background-color: #FFFFFF;
        @include wh(7.5rem,0.8rem);
        margin-left: 1rem;
        margin-top: 0.25rem;
        @include borderRadius(0.4rem);


        .search{
          background-color: transparent;
          @include wh(6rem, 0.8rem);
          font-size: 0.6rem;
          text-indent: 0.5rem;
          position: relative;
          top: -0.28rem;
        }

        .icon_style{
          font-size: 0.6rem;
          color: #666;
          fill: #ccc;
          position: relative;
          top: -0.2rem;
        }
      }
    }

    .headRight{
      flex: 1;
      display: flex;
      text-align: center;
      flex-direction: column;
      align-items: center;

      .icon_style{
        font-size: 0.9rem;
        color: #666;
        fill: #ccc;
      }
    }

  }

  span,input{
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
  }

  ::-webkit-input-placeholder{
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
    color: #666;
    text-indent: 0.5rem;
  }
  :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
    color: #666;
    text-indent: 0.5rem;
  }
  ::-moz-placeholder { /* Mozilla Firefox 19+ */
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
    color: #666;
    text-indent: 0.5rem;
  }
  :-ms-input-placeholder { /* Internet Explorer 10+ */
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
    color: #666;
    text-indent: 0.5rem;
  }

</style>
